package cn.tedu.eguser1.base.exception;

import cn.tedu.eguser1.base.response.JsonResult;
import cn.tedu.eguser1.base.response.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalException {
    @ExceptionHandler
    public JsonResult doHandlerMethodArgumentNotValidException(MethodArgumentNotValidException exception){
        String data = exception.getMessage();
        log.error("MethodArgumentNotValidException:" + data);
        return new JsonResult(StatusCode.OPERATION_VALIDATED_ERROR,data);
    }
}
